﻿import Grawlix from Grawlix
import Grawlix.Services
import Grawlix.Services.Rendering
import Grawlix.Services.Resources

import C5
import System.Xml.XPath

def ToDictionary[of K, V]([required] dict as Hash):
	convert = C5.HashDictionary[of K, V]()
	for item in dict:
		convert.Add(item.Key, item.Value)
	return convert

component "resource_resolver_uri_embedded", EmbeddedResourceResolver
component "resource_resolver_uri_filestream", FileStreamResourceResolver:
	parameters:
		searchPaths:
			array = ("Default/Resources", "Shared/Resources")

component "resource_resolver_uri_game", IUriResolver, GameResourceResolver:
	parameters:
		resolvers:
			array = (@resource_resolver_uri_filestream, @resource_resolver_uri_embedded)

component "resource_resolver_image", ITypedResolver[of WrappedImage], ImageResolver
component "resource_resolver_xml", ITypedResolver[of IXPathNavigable], XmlResolver

component "resource_factory_texture_default", \
	IDynamicResourceFactory[of ITextureResource], \
	DefaultTextureFactory
#component "resource_factory_sprite_default", \
#	IDynamicResourceFactory[of ISpriteResource], \
#	DefaultSpriteFactory

component "environment_factory_appdomain", IEnvironmentFactory, AppDomainEnvironmentFactory:
	searchPaths = "World/Default/Client;Shared"

component "domain_factory_main", IDomainFactory, SingleAssemblyDomainFactory:
	assembly = "main"
	governor = "Grawlix.Test.Default.MainGovernor, Default"
	constraints = (IRenderableArea,)

component "domain_factory_map", IDomainFactory, SingleAssemblyDomainFactory:
	assembly = "maps"
	governor = "Grawlix.Test.Default.MapGovernor, Default"
	constraints = (IRenderableArea,)

component "domain_provider_mapped", IDomainProvider, MappedDomainProvider:
	parameters:
		mapping:
			map(keymap):
				main = @domain_factory_main
		fallback = @domain_factory_map
		mainName = "main"

